package com.ejustcn.vaadinecharts.chart.component;

/**
 * a axis data can indicate a label of category axis.
 *类目型坐标轴文本标签数组，指定label内容。 数组项通常为文本
 */
public class AxisData {
	private String value=null;
	private String color=null;
	
	/**
	 * @param value
	 *          cannot be null;
	 */
	public AxisData(String value){
		if (value==null)
			throw new IllegalArgumentException("Data value cannot be null.");
		this.value=value;
	}
	
	/**
	 * @param value
	 *          cannot be null;
	 */
	public AxisData(String value,String color){
		if (value==null)
			throw new IllegalArgumentException("Data value cannot be null.");
		this.value=value;
		this.color=color;
	}
	
	/**
	 * new value will replace old value;
	 * @param value
	 *          cannot be null;
	 */
	public void setValue(String value){
		if (value==null)
			throw new IllegalArgumentException("Data value cannot be null.");
		this.value=value;
	}
	
	public String getValue(){
		return this.value;
	}
	
	public void setColor(String color){
		this.color=color;
	}
	
	public String getColor(){
		return this.color;
	}
	
	public String toString(){		
		if (color==null){
			return "'"+ value + "'";
		}else{
			StringBuilder s=new StringBuilder();
			s.append("{ ");
			s.append("value:'").append(value).append("',");
			s.append("textStyle:{ color:'").append(color).append("' }");
			s.append(" }");
			return s.toString();
		}
	}
}
